const open             = require('open')
    , webpack          = require('webpack')
    , WebpackDevServer = require('webpack-dev-server')
    ;

let config   = require("./webpack.config.js"),
    compiler = webpack(config),
    server   = new WebpackDevServer(compiler, {
        noInfo: false,
        stats: {colors: true}
    }),
    process1,
    process2;

process1 = new Promise(resolve => {
    compiler.run(()=> {
        resolve();
    });
});
process2 = new Promise(resolve => {
    server.listen(8080, ()=> {
        resolve();
    });
});

Promise.all([process1, process2]).then(()=> {
    console.log('server startup!');
    open('http://localhost:8080');
});
